package com.tengju.bff.interfaces.covercharge.service.impl;

import com.idanchuang.component.redis.util.RedisUtil;
import com.tengju.bff.interfaces.covercharge.constant.BizConstants;
import com.tengju.bff.interfaces.covercharge.entity.vo.RedisVo;
import com.tengju.bff.interfaces.covercharge.service.IRedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;


@Service
@Slf4j
public class RedisServiceImpl  implements IRedisService {

//    @Resource
//    private RedisService redisService;

    /**
     * 设置缓存
     * @param req 请求参数
     * @return
     */
    @Override
    public void setWithdrawSwitchRedis(RedisVo req){
        String lockKey = BizConstants.COVER_CHARGE_WITHDRAW_SWITCH_REDIS;
        RedisUtil.getInstance().set(lockKey, req.getVal());
    }

    /**
     * 查询提现缓存开关缓存
     * @return
     */
    @Override
    public String queryWithdrawSwitchRedis(){
        String lockKey = BizConstants.COVER_CHARGE_WITHDRAW_SWITCH_REDIS;
        return RedisUtil.getInstance().get(lockKey);
    }

    /**
     * 删除提现缓存开关缓存
     * @return
     */
    @Override
    public void delWithdrawSwitchRedis(){
        String lockKey = BizConstants.COVER_CHARGE_WITHDRAW_SWITCH_REDIS;
        String withdraw = RedisUtil.getInstance().get(lockKey);
        if(StringUtils.isNotEmpty(withdraw)){
            RedisUtil.getInstance().del(lockKey);
        }
    }
}
